﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace Examination.Model
{
    /// <summary>
    /// 用户类型
    /// </summary>
    public enum UserType
    {
        /// <summary>
        /// 普通用户
        /// </summary>
        General = 0,

        /// <summary>
        /// 管理员
        /// </summary>
        Admin = 1,

        /// <summary>
        /// 系统管理员
        /// </summary>
        System = 2
    }

    /// <summary>
    /// 用户
    /// </summary>
    public class User : Entity
    {
        /// <summary>
        /// 类型
        /// </summary>
        [Required]
        public UserType Type { get; set; } = UserType.General;

        /// <summary>
        /// 姓名
        /// </summary>
        [Required]
        [MaxLength(10)]
        public string Name { get; set; }

        /// <summary>
        /// 学号
        /// </summary>
        [Required]
        [MaxLength(20)]
        [MinLength(6)]
        public string Number { get; set; }

        /// <summary>
        /// 班级
        /// </summary>
        [Required]
        [MaxLength(50)]
        public string Class { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        [Required]
        [MaxLength(50)]
        public string Password { get; set; }

        public override string ToString()
        {
            return $"{nameof(Type)}: {Type}, {nameof(Name)}: {Name}, {nameof(Number)}: {Number}, {nameof(Class)}: {Class}, {nameof(Password)}: {Password}";
        }
    }
}
